<!doctype html>
<html>
<head>
    <meta charset="utf8">
    <title>@yield('title')</title>
    <meta name="keywords" content="程序，前端，php" />
    <meta name="description" content="前端、php爱好者" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <link href="{{asset ('templates/yq/css/base.css')}}" rel="stylesheet">
    <link href="{{asset ('templates/yq/css/index.css')}}" rel="stylesheet">
    <link href="{{asset ('templates/yq/css/m.css')}}" rel="stylesheet">
    <script src="{{asset('templates/yq/js/jquery-2.1.1.min.js')}}"></script>
    <!--[if lt IE 9]>
    <script src="{{asset('templates/yq/js/modernizr.js')}}"></script>
    <![endif]-->
    <script>
        window.onload = function ()
        {
            var oH2 = document.getElementsByTagName("h2")[0];
            var oUl = document.getElementsByTagName("ul")[0];
            oH2.onclick = function ()
            {
                var style = oUl.style;
                style.display = style.display == "block" ? "none" : "block";
                oH2.className = style.display == "block" ? "open" : ""
            }
        }
    </script>
</head>
<body>
<header>
    <div style="float:right;" id="hub_iframe"></div>
    <div class="tophead">
        <div class="logo"><a href="/">卢建才个人博客</a></div>
        <div id="mnav">
            <h2><span class="navicon"></span></h2>
            <ul>
                <li><a href="/">首页</a></li>
                @category(['pid'=>0])
                <li><a href="{{$v['url']}}">{{$v['cname']}}</a></li>
                @endcategory
                {{--<li><a href="gbook.html">留言板</a></li>|--}}
                {{--<li><a href="/register">注册</a></li>--}}
                {{--<li><a href="/login">登录</a></li>--}}
            </ul>
        </div>
        <nav class="topnav" id="topnav">
            <ul>
                <li><a href="/">首页</a></li>
                @category(['pid'=>0])
                <li><a href="{{$v['url']}}">{{$v['cname']}}</a></li>
                @endcategory
                {{--<li><a href="gbook.html">留言板</a></li>|--}}
                {{--@if(Auth()->check ())--}}
                    {{--<li><a href="register">{{Auth()->user ()->name}}</a></li>--}}
                    {{--<form id="logout" style="display: inline;" action="{{route('logout')}}" method="post">--}}
                        {{--@csrf--}}
                    {{--<li><a id="quit" href="javascript:;">退出</a></li>--}}
                    {{--</form>--}}
                    {{--<script>--}}
                        {{--$(function(){--}}
                            {{--$('#quit').click(function(){--}}
                                {{--$('#logout').submit();--}}
                            {{--})--}}
                        {{--})--}}
                    {{--</script>--}}
                    {{--@else--}}
                {{--<li><a href="register">注册</a></li>--}}
                {{--<li><a href="login">登录</a></li>--}}
                    {{--@endif--}}
            </ul>
        </nav>
    </div>
</header>
<article>
    @yield('content')
    @yield('right')
</article>
<div class="blank"></div>
<footer>
    <p><a href="/">卢建才个人博客 ©版权所有 闽ICP备16024656号-2</a></p>
</footer>
<script src="{{asset('templates/yq/js/nav.js')}}"></script>
<script>
    var aa, dashLine;
    var x = 0;
    var w, h, m;
    var s = 3;
    function ani(obj) {
        var p = getPosition(obj);
        w = obj.offsetWidth;
        // h = obj.clientHeight;
        h=25;
        if (dashLine != null)
            dashLine.style.display = "block";
        else
            dashLine = document.createElement("DIV");
        dashLine.style.position = "absolute";
        dashLine.style.left = p.x + "px";
        dashLine.style.top = (p.y+h) + "px";
        dashLine.style.width = "1px";
        dashLine.style.borderBottom = "2px solid black";
        document.body.appendChild(dashLine);
        aa = setInterval(showLine , 5);
    }

    function showLine()
    {
        if (x <= w)
        {
            dashLine.style.width = x + "px";
            x+=s;
        }
    }

    function out() {
        clearInterval(aa);
        x = 0;
        dashLine.style.display = "none";
    }

    function getPosition(obj)
    {
        var x = obj.offsetLeft;
        var y = obj.offsetTop;
        while(obj = obj.offsetParent)
        {
            x += obj.offsetLeft;
            y += obj.offsetTop;
        }
        return {x:x, y:y}
    }
</script>
<script src="{{asset ('templates/yq/js/zzx.js')}}"></script>
@yield('script')
<script src="{{asset ('templates/yq/js/slh.js')}}"></script>
<script>
    $(function(){
        $.ajaxSetup({
            headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' }
        });

        $('#search').click(function(){
            var search=$('#keyboard').val();
            $.ajax({
                url:'/search',
                data:{'search':search},
                type:'post',
                dataType:'json',
                success:function(data){
                    console.log(typeof data);
                    if(data){
                        console.log(data);
                        var html='';
                        for(var i=0;i<data.length;i++){
                            html+="<li><span class=\"blogpic\"><a href=\"/detail/"+data[i].id+"\"><img src=\""+data[i].thumb+"\"></a></span>\n" +
                                "            <h3 class=\"blogtitle\"><a onmouseover=\"ani(this)\" onmouseout=\"out(this)\" href=\"/detail/"+data[i].id+"\">"+data[i].title+"</a></h3>\n" +
                                "            <div class=\"bloginfo\">\n" +
                                "                <p class=\"introduce\">"+data[i].introduce+"</p>\n" +
                                "            </div>\n" +
                                "            <div class=\"autor\"><span class=\"dtime\">"+data[i].created_at+"</span><span class=\"viewnum\">浏览("+data[i].click+")</span><span class=\"readmore\"><a href=\"/detail/"+data[i].id+"\">阅读原文</a></span></div>\n" +
                                "        </li>";
                        }
                        if(html==''){
                            var p="<p style='padding:30px;background:white;'>没有找到相关文章！换个词试试吧！</p>";
                            $('.infos').remove();
                            $('.blogs').show().html(p);
                        }else{
                            $('.infos').remove();
                            $('.blogs').show().html(html);
                        }

                    }
                }
            });


            return false;
        })
    })
</script>
<script>
    $(function(){
        $('.introduce').each(function(){
            $(this).text(CutString($(this).text(),160,'···'));
        });
        $('.right_p').each(function(){
            $(this).text(CutString($(this).text(),80,'···'));
        });
    })
</script>
</body>
</html>
